import 'reflect-metadata';
import '../polyfills';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { HttpClientModule, HttpClient } from '@angular/common/http';

import { AppRoutingModule } from './app-routing.module';

// NG Translate
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

import { ElectronService } from './providers/electron.service';

import { WebviewDirective } from './directives/webview.directive';

import { AppComponent } from './app.component';
import { HomeComponent } from './components/home/home.component';
import { AboutComponent } from './components/about/about.component';
import { MyComputerComponent } from './components/mycomputer/mycomputer.component';
import { KeyupDirective } from './directives/keyup.directive';
import { DisklistComponent } from './components/disklist/disklist.component';
import { FilelistComponent } from './components/filelist/filelist.component';
import { DialogComponent } from './components/dialog/dialog.component';
import { ZipviewComponent } from './components/zipview/zipview.component';
import { TextviewComponent } from './components/textview/textview.component';
import { ImageviewComponent } from './components/imageview/imageview.component';
import { VideoviewComponent } from './components/videoview/videoview.component';

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    AboutComponent,
    MyComputerComponent,
    WebviewDirective,
    KeyupDirective,
    DisklistComponent,
    FilelistComponent,
    DialogComponent,
    ZipviewComponent,
    TextviewComponent,
    ImageviewComponent,
    VideoviewComponent,
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpClientModule,
    AppRoutingModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: (HttpLoaderFactory),
        deps: [HttpClient]
      }
    })
  ],
  exports: [KeyupDirective, WebviewDirective],
  providers: [ElectronService],
  bootstrap: [AppComponent]
})
export class AppModule { }
